package com.sugon.ohdfs.integration.flink;

import com.google.common.base.Strings;
import org.springframework.boot.DefaultApplicationArguments;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.util.List;
import java.util.Properties;
import java.util.stream.Collectors;

@SpringBootApplication
public class FlinkOhdfsIntegrationTestApplication {

	public static void main(String[] args) {
		DefaultApplicationArguments arguments = new DefaultApplicationArguments(args);
		Properties properties = System.getProperties();
		arguments.getOptionNames().forEach(option -> {
			if(!Strings.isNullOrEmpty(option)){
				List<String> list = arguments.getOptionValues(option);
				if(list!=null && list.size()>0){
					if(list.size()==1){
						properties.put(option, list.get(0));
					}else {
						properties.put(option, list.stream().collect(Collectors.joining(",")));
					}
				}
			}
		});
		SpringApplication.run(FlinkOhdfsIntegrationTestApplication.class, args);
	}

}
